jQuery, selecting form elements by name, getting: Error: uncaught exception: Syntax error, unrecogni

Posted by Mark Steudel on Stack Overflow See other posts from Stack Overflow or by Mark Steudel
Published on 2010-04-13T17:37:50Z Indexed on 2010/04/13 18:23 UTC
Read the original article Hit count: 183

Filed under:

I'm trying to select an select element by name I found this thread showing how to do it, and I followed it but I'm getting Syntax error. I'm using jquery 1.4.1, here's my code.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>TODO supply a title</title>
    <script type="text/javascript" src="/js/jquery-1.4.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
        alert(  $('select[@name="country[0]"]').val() );
        })
    </script>
    </head>
    <body>
    <form>
        <select name="country[0]">
        <option value="23">test</option>
        </select>
    </form>
    </body>
</html>

Thanks in advance for any insight.

MS

© Stack Overflow or respective owner

Related posts about jquery-selectors